﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.UI.WebControls;
using DotNetNuke.Entities.Modules.Communications;

using CharityGamesOnline.Modules.Common;

namespace CharityGamesOnline.Modules.Account
{
    public partial class AccountDetail : CGOBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {                
                if (!Page.IsPostBack)
                {
                    BindData();
                }
            }

            catch (Exception exc)
            {
                //Module failed to load 
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }

        private void BindData()
        {
            AccountController ctrlAccount = new AccountController();
            AccountInfo objAccount = ctrlAccount.GetAccount(PortalId, UserId);
            if (!Null.IsNull(objAccount))
            {
                lbUserID.Text = objAccount.UserID.ToString();
                lbUserName.Text = objAccount.UserName;
                lbToken.Text = string.Format(Localization.GetString("doationFormat", LocalResourceFile), objAccount.Token);
            }
            else
            {
                lbUserID.Text = UserId.ToString();
                lbUserName.Text = UserInfo.Username;
                lbToken.Text = string.Format(Localization.GetString("doationFormat", LocalResourceFile), 0);
            }
        }
    }
}